package com.zhdl.modules.demo.testprocess;

import com.zhdl.modules.process.BaseProcess;

import java.util.List;

public class MainOptImp implements ProcessOptInterface {
    private List<BaseProcess> childList;
    private BaseProcess mainProcess;

    public MainOptImp(List<BaseProcess> childList, BaseProcess mainProcess) {
        this.childList = childList;
        this.mainProcess = mainProcess;
    }


    @Override
    public void start() {
        for (BaseProcess baseProcess : childList) {
            if (baseProcess.process > 0) {
                baseProcess.statusHolder.start();
            }
        }
    }

    @Override
    public void stop() {
        for (BaseProcess baseProcess : childList) {
            baseProcess.statusHolder.stop();
        }
    }

    @Override
    public void release() {
        for (BaseProcess baseProcess : childList) {
            baseProcess.statusHolder.release();
        }
    }

    @Override
    public void reset() {
        for (BaseProcess baseProcess : childList) {
            baseProcess.statusHolder.reset();
        }
    }

    @Override
    public void startProcess(Integer process) {
        mainProcess.startProcess(process);
    }
}
